<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>非单文件组件基本使用</title>
    <script src="../commonjs/vue.js"></script>
</head>
<body>
    <div id="root">
        <!--<h2>学校名称:{{school.name}}</h2>
        <h2>学校地址:{{school.address}}</h2>
        <h2>学生姓名:{{student.name}}</h2>
        <h2>学生年龄:{{student.age}}</h2>-->
        <!--编写组件标签-->
        <school></school>
        <student></student>
    </div>
    <script>
        Vue.config.productionTip = false;//关闭开发提示
        //创建school组件
        const school = Vue.extend({
            template:`
                <div>
                    <h2>学校名称:{{schoolName}}</h2>
                    <h2>学校地址:{{schoolAddress}}</h2>
                </div>
            `,
            data(){
                return{
                    schoolName:'武威职业学院',
                    schoolAddress:'武威市凉州区'
                }
            }
        })
        //创建student组件
        const student = Vue.extend({
            template:`
                <div>
                    <h2>学生姓名:{{studentName}}</h2>
                    <h2>学生年龄:{{studentAge}}</h2>
                </div>
              `,
            data(){
                return{
                    studentName:'姚文昕',
                    studentAge:18
                }
            }
        })
        //注册组件(全局注册：用得少)
/*        Vue.component('school',school)
        Vue.component('student',student)*/
        new Vue({
            el:'#root',
            //注册组件(局部注册：用得多)
            components:{
                school, student
            }
/*            data:{
                school:{
                    name:'武威职业学院',
                    address:'武威市凉州区'
                },
                student:{
                    name:'姚文昕',
                    age:22
                }
            }*/
        })
    </script>
</body>
</html>